package cn.yunhe.springmvc.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

@Configuration  
@EnableWebMvc  
@ComponentScan(basePackages = "cn.yunhe.springmvc")  
public class HelloWorldConfiguration extends WebMvcConfigurerAdapter{  
   
       
    @Override  
    public void configureViewResolvers(ViewResolverRegistry registry) {  
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();  
        viewResolver.setViewClass(JstlView.class);  
        viewResolver.setPrefix("/jsp/");  
        viewResolver.setSuffix(".jsp");  
        registry.viewResolver(viewResolver);  
    }  
       
    @Override  
    public void addResourceHandlers(ResourceHandlerRegistry registry) {  
        registry.addResourceHandler("/static/**").addResourceLocations("/static/");  
    }  
   
}
